/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Validation;

import entity.SystemUserEntity;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;

/**
 *
 * @author sunwei
 */
public class SystemUserSelectOneMenuValidator implements Validator {
    
    // for system user

    @Override
    public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
        SystemUserEntity selection = (SystemUserEntity)value;
        
        if (selection==null){
            FacesMessage message = new FacesMessage();
        message.setDetail("Please select one");
        message.setSummary("Please select one");
        message.setSeverity(FacesMessage.SEVERITY_ERROR);
        throw new ValidatorException(message);
        }
    }
    
}
